package com.geoway.adf.report.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;

/**
 * @Author: lzw
 * @Date: 2024/1/12 16:01
 * @Description:
 */

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {

 @CreatedBy
 private String creator;

 @LastModifiedBy
 private String modifier;

 @Temporal(TemporalType.TIMESTAMP)
 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
 @CreatedDate
 private Date createTime = new Date();

 @Temporal(TemporalType.TIMESTAMP)
 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
 @LastModifiedDate
 private Date modifyTime = new Date();

 public String getCreator() {
  return creator;
 }

 public void setCreator(String creator) {
  this.creator = creator;
 }

 public String getModifier() {
  return modifier;
 }

 public void setModifier(String modifier) {
  this.modifier = modifier;
 }

 public Date getCreateTime() {
  return createTime;
 }

 public void setCreateTime(Date createTime) {
  this.createTime = createTime;
 }

 public Date getModifyTime() {
  return modifyTime;
 }

 public void setModifyTime(Date modifyTime) {
  this.modifyTime = modifyTime;
 }

 @Override
 public String toString() {
  return "BaseEntityModel{" +
          "creator='" + creator + '\'' +
          ", modifier='" + modifier + '\'' +
          ", createTime=" + createTime +
          ", modifyTime=" + modifyTime +
          '}';
 }
}